package com.polaris.live.widget.match_botton

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.polaris.live.R
import com.polaris.live.common.constant.PagConst
import com.polaris.live.databinding.WidgetHomeLiveStartLiveBinding
import org.libpag.PAGScaleMode

/**
 * StartLiveView
 *
 * @author Created by 半仙 on 2024/3/1/001 11:15
 */
class StartLiveView(context: Context, attributeSet: AttributeSet) : ConstraintLayout(context, attributeSet) {

    private val mBinding =
        WidgetHomeLiveStartLiveBinding.inflate(LayoutInflater.from(context), this, true)

    private var mCenterText: String? = null

    init {
        val typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.StartLiveView)
        mCenterText = typedArray.getString(R.styleable.StartLiveView_centerText)
        typedArray.recycle()

        mCenterText?.let {
            mBinding.tvMatch.text = mCenterText
        }
        mBinding.pagRedView.apply {
            path = PagConst.START_MATCH_LONG_3
            setScaleMode(PAGScaleMode.Zoom)
            setRepeatCount(-1)
            play()
        }
    }

    fun setCenterTitle(title: String) {
        mBinding.tvMatch.text = title
    }
}